package com.graduation.adminservice.controller;

import com.graduation.common.domain.dto.PageDTO;
import com.graduation.pojo.dto.LegalDocumentDTO;
import com.graduation.pojo.po.LegalDocument;
import com.graduation.pojo.query.LegalDocumentQuery;
import com.graduation.pojo.vo.LegalDocumentDetailVO;
import com.graduation.pojo.vo.LegalDocumentVO;
import com.graduation.service.LegalDocumentService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/legal-document")
@RequiredArgsConstructor
public class LegalDocumentController {

    private final LegalDocumentService legalDocumentService;

    @GetMapping("/page")
    public PageDTO<LegalDocumentVO> pageLegalDocuments(LegalDocumentQuery query) {
        return legalDocumentService.pageLegalDocuments(query);
    }

    @GetMapping("/list")
    public List<LegalDocument> list() {
        return legalDocumentService.list();
    }

    @GetMapping("/{id}")
    public LegalDocumentDetailVO getLegalDocumentById(@PathVariable(name = "id") Long id) {
        return legalDocumentService.getLegalDocumentById(id);
    }

    @PostMapping
    public void saveLegalDocument(@RequestBody LegalDocumentDTO legalDocumentDTO) {
        legalDocumentService.saveLegalDocument(legalDocumentDTO);
    }

    @PutMapping
    public void updateLegalDocument(@RequestBody LegalDocumentDTO legalDocumentDTO) {
        legalDocumentService.updateLegalDocument(legalDocumentDTO);
    }

    @DeleteMapping("/{id}")
    public void deleteLegalDocument(@PathVariable(name = "id") Long id) {
        legalDocumentService.deleteLegalDocument(id);
    }

}
